package Java攻略._3_流式操作._6_字符串与流之间的转换;

public class _37_检查字符串是否属于回文_java8 {

    public static void main(String[] args) {

        _37_检查字符串是否属于回文_java8 _37 = new _37_检查字符串是否属于回文_java8();
        String target = "123454321";
        boolean isTrue = _37.isPalidrome(target);
        System.out.println(isTrue);
    }
    
    public boolean isPalidrome(String str){
        String zheng = str.toLowerCase().codePoints()
                .filter(Character::isLetterOrDigit)
                .collect(StringBuilder::new,
                        StringBuilder::appendCodePoint,
                        StringBuilder::append)
                .toString();

        String fan = new StringBuilder(zheng).reverse().toString();
        return zheng.equals(fan);
    }
}
